1. Field of the Invention
The invention relates to a method of rewriting a boot program stored in a memory device into a new boot program, an apparatus of doing the same, and a recording medium storing a program therein for causing a computer to carry out the method or to act as the apparatus.
2. Description of the Related Art
There have been suggested a lot of methods of rewriting a program in a memory device, in particular, in a flash memory device.
For instance, Japanese Unexamined Patent Publication No. 11-96779 has suggested a method of rewriting a program in a flash memory device which method is capable of reducing the number of rewriting a program.
In the method, a header area and a program data area are arranged in each of blocks in a physical address associated with a flash memory device, and header areas and program data areas of the blocks are arranged in series in a logic address associated with a processor. When data stored in a program data area N is to be rewritten, it is usually necessary to rewrite a block in the program data area N and a block in the associated header area. However, the program data area N and the associated header area are located in the same block in the physical address of the flash memory device. Accordingly, only the block is rewritten.
Japanese Unexamined Patent Publication No. 11-316687, which is based on U.S. patent application Ser. No. 019178 filed on Feb. 5, 1999 and assigned to Compaq Computer Corporation, has suggested an apparatus for compensating for system error occurring while the system is in a start-up process.
The suggested apparatus is comprised of a read only memory (ROM), a non-volatile random access memory (RAM), and a central processing unit (CPU). The read only memory stores a plurality of bootable flash images, and includes a non-programmable boot block. The non-volatile random access memory stores status data indicative of which flash image was selected. The central processing unit tests as to whether the selected flash image is perfect. If perfect, the central processing unit carries out the selected flash image, and if not, the central processing unit newly selects another flash image. The central processing unit tests as to whether the thus newly selected flash image is perfect, and carries out the selected flash image only when it is perfect. In accordance with the apparatus, since an imperfect flash image is not carried out, it would be possible to automatically recover the system.
Japanese Unexamined Patent Publication No. 6-266552, which is based on U.S. patent application Ser. No. 695952 filed on May 6, 1992 and assigned to Intel Corporation, has suggested a computer system which is capable of dynamically modifying or updating a part of code or data stored in a non-volatile memory device, without detaching any parts such as a cover from the computer system.
Specifically, the computer system is comprised of a processor carrying out a process logic, a non-volatile memory device coupled to the processor and storing data and operating system process logic therein, means coupled to the processor for reading out what is stored in the non-volatile memory device, means coupled to the processor for erasing what is stored in the non-volatile memory device, means coupled to the processor for programming the non-volatile memory device, and means for updating operating system process logic which the operating system process logic is being carried out.
Japanese Unexamined Patent Publication No. 10-177527 has suggested a method of updating data in a flash memory which method avoids data from being erased or from being changed into different data, even if power supply is stopped during data is being updated.
Specifically, the method updates data stored in a flash memory from which data can be erased block by block, and into which data can be written byte by byte. In the method, a flash memory is divided into two blocks. A unit of data is alternately written into the two blocks. When data is to be read out of the two blocks, a latest data unit among data units properly written into the blocks is read out.
Japanese Unexamined Patent Publication No. 8-280679 has suggested a program memory device in which a program can be readily rewritten.
The program memory device is comprised of a flash memory storing various programs and including a plurality of areas into which data can be electrically written and from which data can be electrically erased, a connector arranged externally of the program memory device operating in accordance with a program, and electrically connecting the program memory device to a memory storing a new program to be newly stored into the program memory device, first means for selecting one of a program of the flash memory and the new program stored in the memory, second means for storing the new program into a non-used area in the flash memory, and assigning an executable address to the new program, and a primary memory storing data used for converting the address to be carried out in the second means, into an address of a program stored in the flash memory, data about a degree to which the flash memory is used, and data about a total number of rewriting the flash memory.
If electric power supply to a computer is stopped for some reasons while a boot program stored in the computer is being written, it would be impossible to restart the boot program.
Japanese Unexamined Patent Publication No. 8-255084, which is based on U.S. patent application Ser. No. 375,095 filed on Jan. 18, 1995 and assigned to Hewlett Packard Company, has suggested a method for preventing such a trouble.
FIGS. 1 and 2 are flow charts of the method suggested in Japanese Unexamined Patent Publication No. 8-255084.
Hereinbelow is explained the method in the assumption that a boot program stored in a primary boot block 0 is to be written into a new boot program.
As illustrated in FIG. 2-(A), in an initial state, a boot program is stored in a primary boot block 0, and data is stored in a substitution block 1.
First, as illustrated in FIG. 2-(B), data stored in the substitution block 1 is erased in step 300.
Then, as illustrated in FIG. 2-(C), a boot program stored in the primary boot block 0 is copied into the substitution block 1 in step 310.
Then, a non-volatile memory block circuit (not illustrated) changes an address of the substitution block 1 to such an address that the substitution block 1 can be recognized as a boot block, in step 320.
Then, as illustrated in FIG. 2-(D), a boot program stored in the primary boot block 0 is erased in step 330.
Then, as illustrated in FIG. 2-(E), a new boot program is written into the primary boot block 0 in step 340.
Then, the above-mentioned non-volatile memory block circuit (not illustrated) changes an address of the primary boot block 0 to such an address that the primary boot block 0 into which a new boot program has been stored can be recognized as a boot block, in step 350.
Then, as illustrated in FIG. 2-(F), the boot program which has been copied from the primary boot block 0 is erased from the substitution block 1, in step 360.
Thus, the substitution block 1 which is now empty can be used as an area for storing data therein. Hence, as illustrated in FIG. 2-(G), data is stored into the substitution block 1.
If a boot program has been properly rewritten in the primary boot block 0, the primary boot block 0 absolutely becomes a boot area, as illustrated in FIG. 2-(F). Accordingly, judgment as to whether a boot program has been properly rewritten is made by detecting whether the primary boot block 0 becomes a boot area. Hence, in the conventional method, a boot program has to be copied to the substitution block 1 from the primary boot block 0, as having been explained above, resulting in that extra stress is exerted on a flash memory of the substitution block 1.
In addition, in the conventional method having been explained with reference to FIGS. 1 and 2, it is necessary to copy a boot program stored in the primary boot block 0 into the substitution block 1, and carry out an erasion/writing operation twice to the substitution block 1 in order to erase the boot program copied into the substitution block 1 and use the substitution block 1 as an area for storing data therein.
Specifically, the first rewriting is carried out when the status illustrated in FIG. 2-(B) is transferred to the status illustrated in FIG. 2-(C), and the second rewriting is carried out when the status illustrated in FIG. 2-(F) is transferred to the status illustrated in FIG. 2-(G).
The method or apparatus suggested in the above-mentioned Japanese Unexamined Patent Publications Nos. 11-96779, 11-316687, 6-266552, 10-177527 and 8-280679 has the step of copying a program to a memory block acting as a substitution block, resulting in exertion of extra stress on a flash memory of a memory block acting as a substitution block.
In view of the above-mentioned problems in the conventional methods and apparatuses, it is an object of the present invention to provide a method of rewriting a boot program which method makes it no longer necessary to copy a boot program from a memory block to another memory block when a boot program stored in a memory device is to be rewritten.
It is also an object of the present invention to provide a computer which is capable of doing the same.
In one aspect of the present invention, there is provided a method of rewriting a boot program in a memory device including at least first and second memory blocks to which a boot program can be electrically written and from which a boot program can be electrically erased, the method including the steps of (a) erasing data stored in the first memory block to which a new boot program is to be written, (b) writing a new boot program into the first memory block, (c) changing an address of the first memory block such that the first memory block can be recognized as a boot block, and (d) erasing a boot program out of the second memory block.
In accordance with the above-mentioned method, it is no longer necessary to copy a boot program stored in a memory block (the second memory block) into another memory block acting as a substitution block (the first memory block), unlike the above-mentioned conventional method, and it is possible to write a new boot program directly into the first memory block acting as a substitution block. Hence, an erasion/writing operation of a boot program to the first memory block acting as a substitution block is carried out only once, whereas the same operation had to be carried out twice in the conventional method. The method makes it possible to reduce the number of erasion/writing of a boot program to the first memory block acting as a substitution block, ensuring reduction in stress to be exerted on a flash memory of the first memory block, and hence, lengthening a lifetime of the flash memory.
It is preferable that the method further includes the step of writing data about the new boot program into a storage area associated with the first memory block.
This additional step ensures the first memory block to be recognized as a boot block area.
It is preferable that the method further includes the step of judging that a boot program was not properly rewritten, if a boot program is stored in both the first and second memory blocks.
It is preferable that the method further includes the step of judging that a boot program was not properly rewritten, if data about the new boot program is stored in storage areas associated with both the first and second memory blocks.
It is preferable that the memory device includes three or more memory blocks, and two memory blocks among the memory blocks are used.
The method in accordance with the present invention can be applied to a memory device including three or more memory blocks as well as a memory device including two memory blocks. As the memory device includes the greater number of memory blocks, the memory device could have a longer lifetime.
There may be selected a flash memory or a read only memory (ROM) as the memory device.
In another aspect of the present invention, there is provided a computer including (a) a memory device including at least two memory blocks, (b) a controller which controls writing a boot program into the memory blocks and erasing a boot program from the memory blocks, and (c) an address changer which changes an address of the memory blocks, the controller erasing data stored in a first memory block among the memory blocks, writing a new boot program into the first memory block, and erasing a boot program stored in a second memory block among the memory blocks, the address changer changing an address of the first memory block such that the first memory block can be recognized as a boot block.
In accordance with the above-mentioned computer, it is no longer necessary to copy a boot program stored in a memory block (the second memory block) into another memory block acting as a substitution block (the first memory block), unlike the above-mentioned conventional apparatus, and it is possible to write a new boot program directly into the first memory block acting as a substitution block. Hence, an erasion/writing operation of a boot program to the first memory block acting as a substitution block is carried out only once, whereas the same operation had to be carried out twice in the conventional apparatus. The computer makes it possible to reduce the number of erasion/writing of a boot program to the first memory block acting as a substitution block, ensuring reduction in stress to be exerted on a flash memory of the first memory block, and hence, lengthening a lifetime of the flash memory.
It is preferable that the controller writes data about the new boot program into a storage area associated with the first memory block.
The controller ensures that the first memory block is recognized as a boot block area.
It is preferable that the controller judges that a boot program was not properly rewritten, if a boot program is stored in both the first and second memory blocks.
It is preferable that the controller judges that a boot program was not properly rewritten, if data about the new boot program is stored in storage areas associated with both the first and second memory blocks.
There may be selected a flash memory or a read only memory (ROM) as the memory device.
In still another aspect of the present invention, there is provided a recording medium readable by a computer, storing a program therein for causing a computer to carry out the above-mentioned method of rewriting a boot program in a memory device.
There is further provided a recording medium readable by a computer, storing a program therein for causing a computer to act as the above-mentioned computer.
The above and other objects and advantageous features of the present invention will be made apparent from the following description made with reference to the accompanying drawings, in which like reference characters designate the same or similar parts throughout the drawings.